import 'package:flutter/material.dart';

// 组件 额外
import 'package:im_flutter_sdk_example/components/example_widgets_list.dart';
import 'package:im_flutter_sdk_example/components/pull_to_refresh/example.dart';
import 'package:im_flutter_sdk_example/components/a_button/example.dart';
import 'package:im_flutter_sdk_example/components/a_checkbox/example.dart';
import 'package:im_flutter_sdk_example/components/a_dialog/example.dart';
import 'package:im_flutter_sdk_example/components/a_row/example.dart';
import 'package:im_flutter_sdk_example/components/a_stepper/example.dart';
import 'package:im_flutter_sdk_example/pages/achievement/detail.dart';
import 'package:im_flutter_sdk_example/pages/activity/active-sure.dart';
import 'package:im_flutter_sdk_example/pages/activity/active_success.dart';
import 'package:im_flutter_sdk_example/pages/activity/detail.dart';
import 'package:im_flutter_sdk_example/pages/alliance/group_message.dart';
import 'package:im_flutter_sdk_example/pages/attention/index.dart';
import 'package:im_flutter_sdk_example/pages/chatroom_list_page.dart';
import 'package:im_flutter_sdk_example/pages/collection/index.dart';
import 'package:im_flutter_sdk_example/pages/company/info.dart';
import 'package:im_flutter_sdk_example/pages/contacts_list_page.dart';

//  业务 页面
import 'package:im_flutter_sdk_example/pages/expert/detail.dart';
import 'package:im_flutter_sdk_example/pages/history/index.dart';
import 'package:im_flutter_sdk_example/pages/home_page.dart';
import 'package:im_flutter_sdk_example/pages/login/interest_select.dart';
import 'package:im_flutter_sdk_example/pages/login/password_login.dart';
import 'package:im_flutter_sdk_example/pages/login/quick_login.dart';
import 'package:im_flutter_sdk_example/pages/login/select_interest.dart';
import 'package:im_flutter_sdk_example/pages/login/login_bind_phone.dart';
import 'package:im_flutter_sdk_example/pages/login/login_phone.dart';
import 'package:im_flutter_sdk_example/pages/login/reset_password.dart';
import 'package:im_flutter_sdk_example/pages/login/forget_password.dart';
import 'package:im_flutter_sdk_example/pages/login/login_method.dart';
import 'package:im_flutter_sdk_example/pages/login/login_registe.dart';
import 'package:im_flutter_sdk_example/pages/login/select_tags.dart';
import 'package:im_flutter_sdk_example/pages/login/user_agreement.dart';
import 'package:im_flutter_sdk_example/pages/login_page.dart';
import 'package:im_flutter_sdk_example/pages/message/apply_message.dart';
import 'package:im_flutter_sdk_example/pages/message/comment_message.dart';
import 'package:im_flutter_sdk_example/pages/message/group_message.dart';
import 'package:im_flutter_sdk_example/pages/need/detail.dart';
import 'package:im_flutter_sdk_example/pages/news/detail.dart';
import 'package:im_flutter_sdk_example/pages/news/web.dart';
import 'package:im_flutter_sdk_example/pages/order/order_confirm.dart';
import 'package:im_flutter_sdk_example/pages/order/order_detail.dart';
import 'package:im_flutter_sdk_example/pages/order/order_evaluation.dart';
import 'package:im_flutter_sdk_example/pages/order/order_remark.dart';
import 'package:im_flutter_sdk_example/pages/serve/detail.dart';
import 'package:im_flutter_sdk_example/pages/serve/serve-sure.dart';
import 'package:im_flutter_sdk_example/pages/serve/serve_success.dart';
import 'package:im_flutter_sdk_example/pages/tab/index.dart';
import 'package:im_flutter_sdk_example/pages/toolbar/alliance/widgets/alliance_mine.dart';
import 'package:im_flutter_sdk_example/pages/toolbar/alliance/widgets/audit_list.dart';
import 'package:im_flutter_sdk_example/pages/toolbar/alliance/widgets/homepage.dart';
import 'package:im_flutter_sdk_example/pages/toolbar/alliance/widgets/manger.dart';
import 'package:im_flutter_sdk_example/pages/toolbar/alliance/widgets/create.dart';
import 'package:im_flutter_sdk_example/pages/toolbar/alliance/widgets/group_list.dart';
import 'package:im_flutter_sdk_example/pages/toolbar/alliance/widgets/team_manger.dart';
import 'package:im_flutter_sdk_example/pages/toolbar/alliance/widgets/write_goup_name.dart';
import 'package:im_flutter_sdk_example/pages/toolbar/alliance/widgets/publish_moment.dart';
import 'package:im_flutter_sdk_example/pages/toolbar/message/index.dart';
import 'package:im_flutter_sdk_example/pages/toolbar/mine/about.dart';
import 'package:im_flutter_sdk_example/pages/toolbar/mine/account_security.dart';
import 'package:im_flutter_sdk_example/pages/toolbar/mine/index.dart';
import 'package:im_flutter_sdk_example/pages/toolbar/mine/personal_info.dart';
import 'package:im_flutter_sdk_example/stand_ui/stand_button/example_stand_button.dart';
import 'package:im_flutter_sdk_example/stand_ui/stand_dialog/example_stand_dialog.dart';

class Router {
  static final _routes = {
    '/index': (BuildContext context, {Object args}) => MyHomePage(),
    '/message': (BuildContext context, {Object args}) => Message(),
    '/mine': (BuildContext context, {Object args}) => Mine(),

    '/account_security': (BuildContext context, {Object args}) =>
        AccountSecurity(), //账户安全
    '/personal_info': (BuildContext context, {Object args}) =>
        PersonalInfo(), // 用户信息
    '/about': (BuildContext context, {Object args}) => About(), // 关于我们

    '/quick_login': (BuildContext context, {Object args}) =>
        QuickLogin(), // 一键登录
    '/login_method': (BuildContext context, {Object args}) =>
        LoginMethod(), // 登录选择
    '/login_phone': (BuildContext context, {Object args}) => LoginPhone(),
    '/login_password': (BuildContext context, {Object args}) => PasswordLogin(),
    '/login_bind': (BuildContext context, {Object args}) => LoginBind(),
    '/login_registe': (BuildContext context, {Object args}) => LoginRegiste(),
    '/login_reset_password': (BuildContext context, {Object args}) =>
        LoginResetPassword(),
    '/login_forget_password': (BuildContext context, {Object args}) =>
        ForgetPassWord(),
    '/interest_select': (BuildContext context, {Object args}) =>
        InterestSelect(),
    '/select_interest': (BuildContext context, {Object args}) =>
        SelectInterest(),
    '/select_tags': (BuildContext context, {Object args}) => SelectTags(),
    '/expert_detail': (BuildContext context, {Object args}) => ExpertDetail(),
    '/need_detail': (BuildContext context, {Object args}) => NeedDetail(),
    '/act_detail': (BuildContext context, {Object args}) => ActDetail(),
    '/act_sure': (BuildContext context, {Object args}) => ActiveSure(),
    '/act_success': (BuildContext context, {Object args}) => ActiveSuccess(),
    '/serve_detail': (BuildContext context, {Object args}) => ServeDetail(),
    '/serve_sure': (BuildContext context, {Object args}) => ServeSure(),
    '/serve_success': (BuildContext context, {Object args}) => ServeSuccess(),
    '/achievement_detail': (BuildContext context, {Object args}) =>
        AchievementDetail(),
    '/attention': (BuildContext context, {Object args}) => AttentionList(),

    '/collection': (BuildContext context, {Object args}) => CollectionList(),

    '/footprint': (BuildContext context, {Object args}) => FootPrintList(),
    '/alliance_manger': (BuildContext context, {Object args}) =>
        AllianceManger(),
    '/alliance_create': (BuildContext context, {Object args}) =>
        AllianceCreate(),
    '/write_group_name': (BuildContext context, {Object args}) =>
        WriteGroupName(),

    //  我的小组圈子
    '/my_alliance': (BuildContext context, {Object args}) => MyAlliance(),

    '/group_list': (BuildContext context, {Object args}) => GroupList(),
    '/audit_list': (BuildContext context, {Object args}) => AuditList(),
    '/team_manger': (BuildContext context, {Object args}) => TeamManger(),
    //小组主页 【关于我们】
    '/group_info': (BuildContext context, {Object args}) => GroupInfoPage(),

    // 通知相关
    '/group_message': (BuildContext context, {Object args}) => GroupMessage(),
    //评论我的
    '/comment_message': (BuildContext context, {Object args}) =>
        CommentMessage(),
    // 小组申请消息
    '/apply_message': (BuildContext context, {Object args}) => ApplyMessage(),

    '/home_message_tip': (BuildContext context, {Object args}) =>
        HomeGroupMessage(),
    '/publish_tip': (BuildContext context, {Object args}) => PublishTip(),

    '/user_agreement': (BuildContext context, {Object args}) => UserAgreement(),
    '/order_evaluation': (BuildContext context, {Object args}) =>
        OrderEvaluation(),
    '/order_confirm': (BuildContext context, {Object args}) => OrderConfirm(),
    '/order_remark': (BuildContext context, {Object args}) => OrderRemark(),
    '/order_detail': (BuildContext context, {Object args}) =>
        OrderDetail(args: args),

    // 聊天
    '/loginpage': (BuildContext context, {Object args}) => LoginScene(),
    '/chatrooms': (BuildContext context, {Object args}) => EMChatRoomListPage(),
    '/contact_list': (BuildContext context, {Object args}) =>
        EMContactsListPage(),
    // '/im_home': (BuildContext context, {Object args}) => HomePage(),

    //新闻相关
    '/news_detail': (BuildContext context, {Object args}) => NewsDetail(),
    //企业信息
    '/company_info': (BuildContext context, {Object args}) => CompanyPage(),
    '/news_web': (BuildContext context, {Object args}) => NewsWeb(),
    // 组件列表
    '/example_abutton': (BuildContext context, {Object args}) =>
        ExampleAButton(),
    '/example_widgets_list': (BuildContext context, {Object args}) =>
        ExampleWidgetsList(args: args),
    '/example_astepper': (BuildContext context, {Object args}) =>
        ExampleAStepper(),
    '/example_adialog': (BuildContext context, {Object args}) =>
        ExampleADialog(),
    '/example_arow': (BuildContext context, {Object args}) => ExampleARow(),
    '/example_acheckbox': (BuildContext context, {Object args}) =>
        ExampleACheckBox(),
    '/example_pull_to_refresh': (BuildContext context, {Object args}) =>
        ExamplePullToRefresh(),
    '/example_stand_button': (BuildContext context, {Object args}) =>
        ExampleStandButton(),
    '/example_stand_dialog': (BuildContext context, {Object args}) =>
        ExampleStandDialog(),
  };

  static Router _singleton;

  Router._internal();

  factory Router() {
    if (_singleton == null) {
      _singleton = Router._internal();
    }

    return _singleton;
  }

  /// 监听route
  Route getRoutes(RouteSettings settings) {
    String routeName = settings.name;
    final Function builder = Router._routes[routeName];

    print(settings);

    if (builder == null) {
      return null;
    } else {
      return MaterialPageRoute(
          settings: settings,
          builder: (BuildContext context) =>
              builder(context, args: settings.arguments));
    }
  }
}
